<?php
namespace Kxdrmobile\Controller;
use Think\Controller;
class MetalController extends ExtendController {
	public function index(){

		$UGFT = D("UserMetal");
		$UGFT->sid=$this->sid;
		$UGFT->uid=$this->uid;
		$UGFT->limit="0,10";
		$metals = $UGFT->loadMyMetals();

		$this->assign("type_count",count($metals));
		$this->assign("all_count",$all_count);
		$this->assign("metals",$metals);
		$this->assign("gift_count",$gift_count);
		$this->assign("ts",time());
		$this->display();
	}
	
	public function medal(){
		$id = I("id");
		$gtp = I("gtp");
		$gtpn = I("gtpn");
		$pic = I("pic");
		$name = I("name");
		$get = I("get");
		
		$MED = D("HonoraryMedal");
		$MED->sid=$this->sid;
		$MED->id=$id;
		$medal = $MED->getMedal();
		
		$this->assign("id",$id);
		$this->assign("gtp",$gtp);
		$this->assign("gtpn",$gtpn);
		$this->assign("pic",$pic);
		$this->assign("name",$name);
		$this->assign("get",$get);
		$this->assign("medal",$medal);
		$this->display();
	}
	
	public function pickup(){
		$mid = I("mid");
		$MED = D("UserMetal");
		$MED->mid=$mid;
		$MED->uid=$this->uid;
		$MED->sid=$this->sid;
		$re = $MED->picupMedal();
		$this->ajaxReturn($re);
	}
	public function get_my_metals(){
		$index = I("index");
		$UGFT = D("UserMetal");
		$UGFT->sid=$this->sid;
		$UGFT->uid=$this->uid;
		$UGFT->limit="$index+1,10";
		$gifts["gifts"] = array_values($UGFT->loadMyMetals());
		$gifts["all_count"] = $UGFT->getAllCount();
		$this->ajaxReturn($gifts);
	}
}